package cn.cqie.attendance.manager.controller;

import cn.cqie.attendance.common.util.Page;
import cn.cqie.attendance.common.util.PageBean;
import cn.cqie.attendance.manager.pojo.*;
import cn.cqie.attendance.manager.service.AdminLeavesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author king james
 * @create 2021-07-07-{TIME}
 */
@RestController
@Api(tags = "管理员端-请假管理模块")
@RequestMapping("/admin/leaves")
public class AdminLeavesController {
     @Autowired
     private AdminLeavesService adminLeavesService;

    /**
     * 查询所有请假详情
     * @param adminLeavesSearch 组合查询条件
     * @param pageSize 每一页的数量
     * @param pageNum 当前页
     * @return
     */
     @GetMapping("/queryAllLeavesInfo")
     @ApiOperation("查询所有请假详情")
    public PageBean<AdminStudentLeave> queryAllLeavesInfo(AdminLeavesSearch adminLeavesSearch, Integer pageSize, Integer pageNum){
         return adminLeavesService.queryAllLeavesInfo(adminLeavesSearch,pageSize,pageNum);
    }

    /**
     * 根据学生请假id查询学生请假详情
     * @param leaveId
     * @return
     */
    @GetMapping("/queryLeavesInfoById")
    @ApiOperation("根据学生请假id查询学生请假详情")
    @ApiImplicitParam(name = "leaveId",value = "请假id",required = true)
    public Page<AdminStudentLeave> queryLeavesInfoById(Integer leaveId){
         return adminLeavesService.queryLeavesInfoById(leaveId);
    }

    /**
     * 根据学生id查询学生请假附件
     * @param leaveId
     * @return
     */
    @GetMapping("/queryAttachmentInfoById")
    @ApiOperation("根据学生请假id查询学生请假附件")
    @ApiImplicitParam(name = "leaveId",value = "请假id",required = true)
    public Page<AdminAttachment> queryAttachmentInfoById(Integer leaveId){
        return adminLeavesService.queryAttachmentInfoById(leaveId);
    }

    /**
     * 根据学生请假id查询请假管理流程
     * @param leaveId
     * @return
     */
    @GetMapping(("/queryLeaveDistanceById"))
    @ApiOperation("根据学生请假id查询请假管理流程")
    @ApiImplicitParam(name = "leaveId",value = "请假id",required = true)
    public Page<AdminLeavesDistance> queryLeaveDistanceById(Integer leaveId){
        return adminLeavesService.queryLeaveDistanceById(leaveId);
    }
}
